﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace TS_XY_Train_Repaire.ToolSystem
{
    public partial class Tool_System_ToolPos_Form : DevExpress.XtraEditors.XtraForm
    {
        public Tool_System_ToolPos_Form()
        {
            InitializeComponent();
        }

        private void Tool_System_ToolPos_Form_Load(object sender, EventArgs e)
        {
            _LoadGrid();
        }

        // 加载工具列表
        private void _LoadGrid()
        {
            //try
            //{
            //    gc_main.DataSource = ToolDataMgr.GetInstance().GetToolPosDataTable();
            //}
            //catch
            //{
            //    gc_main.DataSource = null;
            //    gc_main.Refresh();
            //}
        }

        private void bbi_add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Tool_System_ToolPosEdit_Form oForm = new Tool_System_ToolPosEdit_Form();
            if (oForm.ShowDialog() == DialogResult.OK)
            {
                _LoadGrid();
            }
        }

        private void bbi_modify_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //int index = gv_Tool.GetFocusedDataSourceRowIndex();
            //if (index < 0)
            //{
            //    return;
            //}

            //DataRow vCurrenRow = gv_Tool.GetFocusedDataRow();
            //Tool_System_ToolPosEdit_Form oForm = new Tool_System_ToolPosEdit_Form();
            //oForm.OToolPos.IID = (int)vCurrenRow[0];
            //oForm.OToolPos.SName = vCurrenRow[1].ToString();

            //if (oForm.ShowDialog() == DialogResult.OK)
            //{
            //    _LoadGrid();
            //}
        }

        private void bbi_delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //int index = gv_Tool.GetFocusedDataSourceRowIndex();
            //if (index < 0)
            //{
            //    return;
            //}

            //int iID = (int)gv_Tool.GetFocusedDataRow()[0];

            //MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            //String strMsg = "确定要删除序号为" + iID.ToString() + "的库房位置吗？";
            //DialogResult dr = MessageBox.Show(strMsg, "删除工具", messButton);
            //if (dr == DialogResult.OK)//如果点击“确定”按钮
            //{
            //    if (ToolDataMgr.GetInstance().DeleteToolPos(iID))
            //    {
            //        _LoadGrid();
            //    }
            //}
        }
    }
}